#include "functions.h"

void printout(char map[][WIDTH])
{
    //reset the couse to 0,0
    gotoxy(0, 0);
    /*打印板*/
    char *p;
    p = &map[0][0];

    int a = 0;
    while (p < &map[HEIGHT - 1][WIDTH - 1] + 1)
    {
        if (a == WIDTH)   
        {
            printf("\n");
            a = 0;
        }
        printf("%c", *p++);
        a++;
    }
}


void upd_screen(char map[][WIDTH], char pre_map[][WIDTH])
{
    for (int i = 0; i < HEIGHT; i++)
    {
        for (int k = 0; k < WIDTH; k++)
        {
            if (map[i][k] != pre_map[i][k])
            {
                gotoxy(k, i);
                printf("%c", map[i][k]);
            }
            pre_map[i][k] = map[i][k];
        }
    }
}

void delay(int milisec)
{
    int begain = clock();
    while (clock() < begain + milisec);
}
